package com.gz.util;

import java.util.ArrayList;
import java.util.List;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import com.gz.bean.CartInfo;

public class CartUtil {
	public static List<CartInfo> getCartInfo(String retStr) {
		List<CartInfo> cartList = new ArrayList<CartInfo>();
		Document doc = Jsoup.parse(retStr);
		Elements blogList = doc.select("div[class=xcr-info2-content]");
		if(blogList!=null && blogList.size()>0) {
			for( Element element : blogList ){
				CartInfo cartInfo = new CartInfo();
				String goodsid = element.select("input[name='gid']").attr("value");
				String productid = element.select("input[name='pid']").attr("value");
				String recordID = element.select("input[name='recordID']").attr("value");
				cartInfo.setGoodsid(goodsid);
				cartInfo.setProductid(productid);
				cartInfo.setRecordID(recordID);
				cartInfo.setProductcount("0");
				cartList.add(cartInfo);
			}
		}
		return cartList;
	}
}
